package com.itfitness.arraycopy;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
    static {
        System.loadLibrary("native-lib");
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Student[] srcStus = new Student[10];
        //对源数组的赋值
        for(int i = 0 ; i < srcStus.length ; i ++){
            String name = "姓名:" + i;
            srcStus[i] = new Student(name ,i);
        }
        //创建目标数组
        Student[] dstStus = new Student[srcStus.length];

        //进行数组的拷贝
        arrayCopy(srcStus,0,dstStus,0,srcStus.length);

        //打印拷贝后的数组
        for (Student stu : dstStus) {
            Log.e("结果:",stu.toString());
        }
    }
    /**
     * 数组拷贝
     * @param arraySrc 源数组
     * @param srcPos 源数组开始拷贝的位置
     * @param arraDst 目标数组
     * @param dstPos 目标数组开始赋值的位置
     * @param copyLength 拷贝的长度
     */
    public native void arrayCopy(Object arraySrc,int srcPos,Object arraDst,int dstPos,int copyLength);
}
